package com.lovo.stock.controller;

import com.lovo.stock.utils.FileUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 文件上传
 */
@RestController
@RequestMapping("/file")
public class FileController {
    @PostMapping("/uploadFileAbsolute")
    public String uploadFileAbsolute(@RequestParam("goodPicture") MultipartFile multipartFile)  {
        String newFileName= null;
        try {
            newFileName = FileUtils.uploadFileAbsolute(multipartFile);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return newFileName;
    }
}
